/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.yunhoo.sys.login;

import java.io.IOException;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

/**
 *
 * @author Administrator
 */
@ManagedBean(name = "logoutBean")
@ViewScoped
public class LogoutBean implements Serializable {

    public void exit() {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        try {
            HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(false);
            System.out.println(" exit sessionId : " + session.getId());
            session.invalidate();
            facesContext.getExternalContext().redirect("login.jsf");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
